﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Web.UI;
using Antu.WebControls;
using Antu.Core.Components;
using Antu.Core.Services;
using System.Web.UI.WebControls;
using EluZSProvider;
using System.Web;
using System.Data;

namespace WebSys.UI.Control.ZhengShou
{
    public class EditUser3Control : MPBasicTemplate
    {
        EluZSDataProvider _EluZSDataProvider = (EluZSDataProvider)ProviderService.ProviderServiceMange.GetProvider("EluZSProvider");
        MPPersistence Persistence1;
        TextBox txtID, txtQYID;
        Label 征收实施单位, 人员类别;
        public string userid = string.Empty;
        protected override void OnLoad(EventArgs e)
        {
            if (HttpContext.Current.Session["UserID"] == null)
            {
                Antu.Utilities.UtilitiesPage.AlertDialogClear("登录超时，请重新登录！", "window.parent.location.href('../login.aspx');");
            }
            else
            {
                userid = HttpContext.Current.Session["UserID"].ToString();
            }
            base.OnLoad(e);
            Persistence1 = (MPPersistence)FindControl("Persistence1");
            txtID = (TextBox)FindControl("txtID");
            txtQYID = (TextBox)FindControl("txtQYID");
            征收实施单位 = (Label)FindControl("征收实施单位");
            人员类别 = (Label)FindControl("人员类别");
            Panel panel1 = (Panel)FindControl("panel1");
            string strid = base.Page.Request["ID"];
            if (!base.Page.IsPostBack)
            {
                Persistence1.Table = "ZS_PGJGRY";
                Persistence1.Key = "ID";
                Persistence1.KeyValue = HttpContext.Current.Request["ID"];
                Persistence1.ConnStr = _EluZSDataProvider.GetConnectionString();
            }
            Persistence1.BindControl = panel1;
            Button btn_Insert = (Button)FindControl("btn_Insert");
            btn_Insert.Click += new EventHandler(btnSave_Click);
        }
        protected override void OnPreRender(EventArgs e)
        {
            base.OnPreRender(e);
            string strCID = base.Page.Request["CID"];
            if (!string.IsNullOrEmpty(strCID))
            {
                txtQYID.Text = strCID;
                征收实施单位.Text = _EluZSDataProvider.GetSomeStr("zs_company", "单位名称", "id", strCID);
            }
            string strID = base.Page.Request["ID"];
            if (!string.IsNullOrEmpty(strID))
            {
                人员类别.Text = _EluZSDataProvider.GetSomeStr("zs_pgjgry", "RYLB", "id", strID);
            }
            if (string.IsNullOrEmpty(strID)) { txtID.Text = System.Guid.NewGuid().ToString().Replace("-", "").ToUpper(); } else { txtID.Text = strID; }
        }
        protected void btnSave_Click(object sender, EventArgs e)
        {
            string strCID = base.Page.Request["CID"];
            Persistence1.Update();
            HttpContext.Current.Response.Redirect("EditSSComPerson.aspx?type=edit&CID=" + strCID);
        }
        
    }
}


